package com.maozzi.api.auth.util;

import com.google.gson.Gson;
import com.maozzi.api.auth.model.UserInfo;
import org.slf4j.MDC;

/**
 * 单点登录工具
 *
 * @author maozi
 */
public class SsoUtil {
    private final static Gson GSON = new Gson();

    public static void set(UserInfo userInfo) {
        MDC.put(Thread.currentThread().getName(), GSON.toJson(userInfo));
    }

    public static UserInfo get() {
        String s = MDC.get(Thread.currentThread().getName());
        return GSON.fromJson(s, UserInfo.class);
    }
}
